<template>
  <main class="app-main">
    <Suspense>
      <template #default>
        <router-view v-slot="{ Component, route }">
          <transition name="fade-transform" mode="out-in">
            <keep-alive :include="cachedViews">
              <component :is="Component" :key="route.fullPath" />
            </keep-alive>
          </transition>
        </router-view>
      </template>
      <template #fallback>Loading...</template>
    </Suspense>
  </main>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue'
import { useStore } from 'vuex'
import BlankLayout from '../BlankLayout.vue'

export default defineComponent({
  components: { BlankLayout },
  name: 'AppMain',
  setup() {
    const store = useStore()

    const cachedViews = computed(() => store.getters.cachedViews)

    return {
      cachedViews
    }
  }
})
</script>

<style lang="scss" scoped>
.app-main {
  position: relative;
  margin: 24px;
}
</style>
